import moment from 'moment';

let dates = [];
let inData = [];
let outData = [];

const range = [80, 100];

for (let i = 0; i <= 7 * 24; i++) {
    const value = (Math.random() * (range[1] - range[0]) + range[0]).toFixed(2);
    const value2 = (Math.random() * (range[1] - range[0]) + range[0]).toFixed(2);
    dates.push(moment().subtract(7 * 24 - i, 'hour').format('YYYY-MM-DD HH:mm:SS'));
    inData.push(value);
    outData.push(value2);
}

export const bandwidthOption = {
    color: ['#348EED', '#FBDF90'],
    title: {
        text: '出入带宽(Mbps)'
    },
    tooltip: {
        trigger: 'axis'
    },
    toolbox: {
        feature: {
            saveAsImage: { name: 'DHCP', title: '保存' }
        }
    },
    dataZoom: [
        {
            show: true,
            realtime: true,
            xAxisIndex: [0, 1]
        }
    ],
    grid: [{
        top: '15%',
        left: 50,
        right: 50,
        height: '40%'
    }, {
        left: 50,
        right: 50,
        top: '55%',
        height: '35%'
    }],
    xAxis: [
        {
            type: 'category',
            show: false,
            data: dates
        },
        {
            gridIndex: 1,
            show: false,
            type: 'category',
            data: dates
        }
    ],
    yAxis: [
        {
            type: 'value',
            max: 200,
        },
        {
            gridIndex: 1,
            type: 'value',
            inverse: true,
            max: 200,
        }
    ],
    series: [
        {
            name: '总输入带宽',
            type: 'line',
            hoverAnimation: false,
            areaStyle: {
                normal: {}
            },
            data: inData
        },
        {
            name: '总输出带宽',
            type: 'line',
            xAxisIndex: 1,
            yAxisIndex: 1,
            areaStyle: {
                normal: {}
            },
            data: outData
        }
    ]
};
